﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;

namespace WgpgCore
{
    public class ExternalReadOnlyObservableCollection<T> : ReadOnlyCollection<T>, INotifyCollectionChanged
    {
        private readonly ObservableCollection<T> _collection;

        public ExternalReadOnlyObservableCollection(ObservableCollection<T> collection) : base(collection)
        {
            _collection = collection;
            _collection.CollectionChanged += OnCollectionChanged;
        }

        public event NotifyCollectionChangedEventHandler CollectionChanged;

        private void OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
        {
            if (CollectionChanged != null)
                CollectionChanged(sender, args);
        }
    }
}
